package com.sto.stoapp.adapter;

import java.util.Vector;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.sto.stoapp.activity.R;
import com.sto.stoapp.file.LogFileListItem;

public class LogFileListAdapter extends BaseAdapter{

	private Context mContext;
	private Vector<LogFileListItem> mItems;

	public LogFileListAdapter(Context context,Vector<LogFileListItem> mItems) {
		mContext = context;
		this.mItems = mItems;
	}

	public void addItem(LogFileListItem item) {
		mItems.add(item);
	}

	public int getCount() {
		return mItems.size();
	}

	public LogFileListItem getItem(int position) {
		return (LogFileListItem) mItems.elementAt(position);
	}

	public long getItemId(int position) {
		return position;
	}

	public int getItemType(int position) {
		return getItem(position).type;
	}

	public void clearItems() {
		mItems.clear();
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		Holder holder;
		if (convertView == null) {
			holder = new Holder();
			LayoutInflater inflate = (LayoutInflater) mContext
					.getSystemService(android.content.Context.LAYOUT_INFLATER_SERVICE);
			convertView = (LinearLayout) inflate.inflate(R.layout.log_file_list_item,
					null);
			holder.tv = (TextView) convertView
					.findViewById(R.id.filelist_textview_item_content);
			convertView.setTag(holder);
		} else {
			holder = (Holder) convertView.getTag();
		}

		holder.tv.setText(getItem(position).name);

		return convertView;
	}

	class Holder {
		TextView tv;
	}

	
}
